package com.sandasai.action.admin;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.sandasai.service.AdminManager;
import com.sandasai.vo.SettingBean;
@Controller
@Scope("prototype")
public class SetTimeAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Resource
	private AdminManager adminManager;
	private String startTimeOfRegistration;
	private String endTimeOfRegistration;
	private String startTimeOfSubmission;
	private String endTimeOfSubmission;
	
	public String getStartTimeOfRegistration() {
		return startTimeOfRegistration;
	}

	public void setStartTimeOfRegistration(String startTimeOfRegistration) {
		this.startTimeOfRegistration = startTimeOfRegistration;
	}

	public String getEndTimeOfRegistration() {
		return endTimeOfRegistration;
	}

	public void setEndTimeOfRegistration(String endTimeOfRegistration) {
		this.endTimeOfRegistration = endTimeOfRegistration;
	}

	public String getStartTimeOfSubmission() {
		return startTimeOfSubmission;
	}

	public void setStartTimeOfSubmission(String startTimeOfSubmission) {
		this.startTimeOfSubmission = startTimeOfSubmission;
	}

	public String getEndTimeOfSubmission() {
		return endTimeOfSubmission;
	}

	public void setEndTimeOfSubmission(String endTimeOfSubmission) {
		this.endTimeOfSubmission = endTimeOfSubmission;
	}

	public String execute() {
		ActionContext ctx = ActionContext.getContext();
		SettingBean settingBean = adminManager.getSettingBean();
		ctx.put("startTimeOfRegistration", settingBean.getStartTimeOfRegistration());
		ctx.put("endTimeOfRegistration", settingBean.getEndTimeOfRegistration());
		ctx.put("startTimeOfSubmission", settingBean.getStartTimeOfSubmission());
		ctx.put("endTimeOfSubmission", settingBean.getEndTimeOfSubmission());
		if(adminManager.setTime(startTimeOfRegistration, endTimeOfRegistration, startTimeOfSubmission, endTimeOfSubmission)) {
			ctx.put("message", "时间设置成功！");
		}else {
			ctx.put("message", "时间设置失败！");
		}
		return SUCCESS;
	}
	
}